<template>
	<view>
		<an-nav-bar title="技师广场" :navHeight="false"> </an-nav-bar>
		<view class="tabr flex">
			<view :class="{'check':checkId == 1}" @click="onTab(1)">热门</view>
			<view :class="{'check':checkId == 2}" @click="onTab(2)">附近</view>
			<view :class="{'check':checkId == 3}" @click="onTab(3)">新人</view>
			<view :class="{'check':checkId == 4}" @click="onTab(4)">活跃</view>
		</view>
		<view class=""></view>
		<view class="list">
			<view class="item flex" v-for="(item,idx) in technicianList" :key="idx" @click="gotoUrl(item)">
				<view class="left">
					<image :src="$common.binImage(item.headImg)" mode="aspectFill"></image>
				</view>
				<view class="right">
					<view class="flex top">
						<view class="name">{{item.nickName}}</view>
						<view :class="[item.sex == 0 ? 'sex0':'sex1','sex']"></view>
						<view class="age">{{item.age || '18'}}</view>
						<view class="tag">
							<view class="">{{item.jobTitle || '未设置'}}</view>
						</view>
						<view class="address flex">{{item.city || ''}}</view>
					</view>
					<view v-if="item.hobbies" class="lbls flex">
						<view class="" v-for="(hitem,hidx) in item.hobbies.split(',')" :key="hidx">{{hitem}}</view>
					</view>
					<view class="text">自我介绍：{{item.selfIntroduction}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import indexConfig from '@/config/index.config';
	export default {
		data() {
			return {
				checkId: 1,
				technicianList: [],
				backUrl: '',
				form: '&orderByColumn=t.view_num desc, t.id&isAsc=desc'
			};
		},
		onLoad() {
			this.getList()
		},
		methods: {
			gotoUrl(item){
				uni.navigateTo({
					url:'/pages/my/technicianSquareInfo?id=' + item.id
				})
			},
			onTab(id) {
				this.checkId = id
				if (id == 1) {
					this.form = '&orderByColumn=t.view_num desc, t.id&isAsc=desc'
				} else if (id == 2) {
					this.form = '&longitude=xxx&latitude=xxx'
				} else if (id == 3) {
					this.form = '&orderByColumn=t.create_time desc, t.id & isAsc=desc'
				} else {
					this.form = ''
				}
				this.technicianList = []
				this.getList()
			},
			getList() {
				this.$http.get('/appNoAuth/store/massageTechnician/list?accountType=1&squareVisit=true' + this.form).then(res => {
					this.technicianList = res.rows
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.list {
		padding: 188rpx 24rpx 16rpx;

		.item {
			background: #fff;
			width: 100%;
			height: 270rpx;
			box-sizing: border-box;
			padding: 20rpx 30rpx;
			border-bottom: 10rpx solid #f8f8f8;
			position: relative;
			border-radius: 10rpx;
			z-index: 10;
			align-items: flex-start !important;
			overflow: hidden;

			.left {
				width: 220rpx;
				height: 220rpx;
				position: relative;

				image {
					width: 220rpx;
					height: 220rpx;
					border-radius: 10rpx;
				}
			}

			.right {
				padding-left: 20rpx;
				flex: 1;

				.text {
					color: #999;
					font-size: 26rpx;
					display: -webkit-box;
					overflow: hidden;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					word-break: break-all;
				}

				.lbls {
					padding: 20rpx 0 18rpx;
					box-sizing: border-box;
					max-width: 450rpx;
					overflow: hidden;

					>view {
						display: block;
						line-height: 50rpx;
						text-align: center;
						min-width: 30rpx;
						height: 50rpx;
						background: #f4f4f4;
						border-radius: 26rpx;
						color: #666;
						font-size: 26rpx;
						margin-right: 10rpx;
						white-space: nowrap;
						padding: 0 8rpx;
						box-sizing: border-box;
					}
				}

				.top {
					.address {
						color: #999;
						font-size: 24rpx;
						flex: 1;
						justify-content: flex-end;
					}

					.name {
						color: #333;
						font-size: 30rpx;
						display: block;
						max-width: 200rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.sex {
						display: block;
						width: 24rpx;
						height: 24rpx;
						margin: 0 10rpx;
					}

					.sex0 {
						background: url(/static/sex0.png) no-repeat 50%;
						background-size: 100% auto;
					}

					.sex1 {
						background: url(/static/sex1.png) no-repeat 50%;
						background-size: 100% auto;
					}

					.age {
						color: #666;
						font-size: 26rpx;
						margin-right: 10rpx;
						font-weight: 400;
					}

					.tag {
						flex: 1;

						>view {
							display: inline-block;
							padding: 0 10rpx;
							height: 36rpx;
							line-height: 36rpx;
							text-align: center;
							z-index: 10;
							background: linear-gradient(90deg, #d7b075, #aa8050);
							white-space: nowrap;
							border-radius: 6rpx;
							color: #fff;
							font-size: 24rpx;
						}
					}
				}
			}
		}
	}

	.tabr {
		width: 100%;
		height: 88rpx;
		position: fixed;
		top: calc(var(--status-bar-height) + 88rpx);
		left: 0;
		background-color: #fff;
		box-sizing: border-box;
		z-index: 999;

		>view {
			width: 120rpx;
			height: 88rpx;
			text-align: center;
			line-height: 88rpx;
			font-size: 30rpx;
			color: #666;
		}

		.check {
			color: #aa8050;
			position: relative;

			&::after {
				display: block;
				content: "";
				width: 80%;
				height: 4rpx;
				background: #aa8050;
				border-radius: 2rpx;
				position: absolute;
				left: 10%;
				bottom: 10rpx;
			}
		}
	}

	
</style>
